import os
import cv2

need_transpose = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

# need_transpose = [3, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0]

# need_transpose = [1, 1, 0, 1, 1, 1, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0]

# need_transpose = [1,1,1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
need_transpose = [3,3,3, 0, 1, 0, 3,3,3, 3,3,3, 0, 0, 0, 0, 0, 0]
for root_root, root_dirs, root_files in os.walk(r"E:\dataset\UTA-RLDD\Fol"
                                                r"d2_part2"):
    i = 0
    for dir_name in root_dirs:
        for c_root, c_dirs, c_files in os.walk(os.path.join(root_root, dir_name)):
            # 获取文件路径
            print("\n")
            for file in c_files:
                cap = cv2.VideoCapture(os.path.join(c_root, file))
                number = cap.get(7)
                width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
                height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
                cap.release()
                if need_transpose[i] == 1 or need_transpose[i] == 3:
                    temp = width
                    width = height
                    height = temp
                print("cut_video_by_video(r'{}\\{}', \"{}\", [{}, {}, {}, {}],{})".format(
                    root_root, dir_name, file,
                    int(int(height * 0.1) / 100) * 100, int(int(height * 0.3) / 100) * 100,
                    int(int(width * 0.1) / 100) * 100, int(int(width * 0.1) / 100) * 100,
                    need_transpose[i]
                ))
                i = i + 1
